import sys
import serial.tools.list_ports
import ctypes


def get_available_ports():
    ports = list(serial.tools.list_ports.comports())
    available_ports = []
    for port in ports:
        if port.device not in available_ports:
            available_ports.append(port.device)
    return available_ports


def show_notification(message):
    ctypes.windll.user32.MessageBoxW(0, message, "龙威提醒您", 0x40 | 0x1)


if __name__ == "__main__":
    ports = get_available_ports()
    if ports:
        message = "当前可用串口：" + ", ".join(ports)
        show_notification(message)
    else:
        show_notification("没有找到可用串口")
